package com.gitee.huxing.course.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gitee.huxing.course.domain.dao.AccountMapper;
import com.gitee.huxing.course.domain.module.AccountDO;
import com.gitee.huxing.course.service.AccountOrderService;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hmily.annotation.HmilyTCC;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.service
 * @ClassName: AccountService
 * @Author: huxing
 * @DateTime: 2021-10-08 下午6:09
 */
@Slf4j
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountDO> implements AccountOrderService {

    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    @HmilyTCC(confirmMethod = "confirmMethod", cancelMethod = "cancelMethod")
    public void apply(AccountDO accountDO) {
        this.baseMapper.insert(accountDO);
        int i = 1/0;
    }

    public void confirmMethod(AccountDO accountDO) {
        log.info("confirm method: {}", accountDO.toString());
    }

    public void cancelMethod(AccountDO accountDO) {
        log.info("cancel method: {}", accountDO.toString());
    }
}
